import { baseUrl } from "../../sheep/request/baseUrl";
import { getAddressApi,bindSuperiorApi } from "@/sheep/api/index";

// 获取图片地址
export const getImgUrl = (url) => baseUrl + url

export const getAddress = () => {
    return new Promise((resolve, reject) => {
        uni.getLocation({
            type: "gcj02",
            success: function (res) {
                const addressForm = {
                    location: res.latitude + "," + res.longitude,
                };
                getAddressApi(addressForm).then((res) => {
                    resolve(res.data);
                });
            },
            fail: function (err) {
                console.log("获取位置报错", err);
            },
        });
    });
}

// 绑定邀请人id
export const bindAgentId = () => {
    bindSuperiorApi(uni.getStorageSync('bindAgentId')).then(res => {
        if (res.code === 200) {
            uni.removeStorageSync('bindAgentId');
        }
    })
}
